using UnityEngine;

namespace CinemaDirector
{
	[CutsceneItem("GG-Action", "Move")]
	public class MoveFromToAction : CinemaActorAction
	{
		public GGVPosition startPosition;

		public GGVPosition endPosition;

		public bool useEase;

		public AnimationCurve easeCurve;

		protected Transform actorTransform;

		public override void Initialize()
		{
			base.Initialize();
			startPosition.Init(base.Cutscene.variables);
			endPosition.Init(base.Cutscene.variables);
		}

		public override void Trigger(GameObject actor)
		{
			if (!(actor == null))
			{
				actorTransform = actor.transform;
				startPosition.value.currentPosition = actorTransform.position;
				endPosition.value.currentPosition = actorTransform.position;
				SetTime(0f);
			}
		}

		public override void End(GameObject actor)
		{
			if (!(actor == null))
			{
				actorTransform = actor.transform;
				startPosition.value.currentPosition = actorTransform.position;
				endPosition.value.currentPosition = actorTransform.position;
				SetTime(1f);
			}
		}

		public override void UpdateTime(GameObject Actor, float time, float deltaTime)
		{
			if (!(duration <= 0f) && !(actorTransform == null))
			{
				float time2 = time / duration;
				SetTime(time2);
			}
		}

		private void SetTime(float normTime)
		{
			if (useEase)
			{
				normTime = easeCurve.Evaluate(normTime);
			}
			Vector3 worldPosition = startPosition.value.GetWorldPosition(actorTransform);
			Vector3 worldPosition2 = endPosition.value.GetWorldPosition(actorTransform);
			actorTransform.position = Vector3Ex.LerpNotClamped(worldPosition, worldPosition2, normTime);
		}
	}
}
